package com.nageoffer.shortlink.project.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nageoffer.shortlink.common.convention.result.Result;
import com.nageoffer.shortlink.common.convention.result.Results;
import com.nageoffer.shortlink.common.dto.project.req.ShortLinkStatsReqDTO;
import com.nageoffer.shortlink.common.dto.project.resp.ShortLinkStatsAccessRecordRespDTO;
import com.nageoffer.shortlink.common.dto.project.resp.ShortLinkStatsRespDTO;
import com.nageoffer.shortlink.project.dto.req.ShortLinkStatsAccessRecordReqDTO;
import com.nageoffer.shortlink.project.service.ShortLinkStatsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/short-link/stats")
public class ShortLinkStatsController {
    private final ShortLinkStatsService shortLinkStatsService;
    @GetMapping
    public Result<ShortLinkStatsRespDTO> shortLinkStats(ShortLinkStatsReqDTO requestParam) {
        return Results.success(shortLinkStatsService.oneShortLinkStats(requestParam));
    }

    @GetMapping("/access-record")
    public Result<Page<ShortLinkStatsAccessRecordRespDTO>> pageShortLinkStats(ShortLinkStatsAccessRecordReqDTO requestParam) {
        return Results.success(shortLinkStatsService.pageShortLinkStats(requestParam));
    }
}
